home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Software Contest 3
/
FM Towns Software Contest 3.iso
/
exp
/
astral
/
a1
/
game
/
source
/
star.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-07
|
4KB
|
120 lines
// "star.c"
// 背景(宇宙空間)を表示
#include "wire3d.h"
#include "sin8.c"
void star(ANGLE *angle,int page)
{
int i,x,y,z_w;
int point_w[4][3];
#define STAR_NUM 38
int star_data[STAR_NUM][3]={{ 100000, 100000, 100000},
{-100000, 100000, 100000},
{ 100000,-100000, 100000},
{-100000,-100000, 100000},
{ 100000, 100000,-100000},
{-100000, 100000,-100000},
{ 100000,-100000,-100000},
{-100000,-100000,-100000},
{- 60000, 30000, 100000},
{- 20000,- 40000, 100000},
{ 10000, 50000, 100000},
{ 15000,- 80000, 100000},
{ 70000,- 10000, 100000},
{ 60000,- 30000,-100000},
{ 20000, 40000,-100000},
{- 10000,- 50000,-100000},
{- 15000, 80000,-100000},
{- 70000, 10000,-100000},
{ 60000, 100000,- 30000},
{ 20000, 100000, 40000},
{- 10000, 100000,- 50000},
{- 15000, 100000, 80000},
{- 70000, 100000, 10000},
{ 60000,-100000,- 30000},
{ 20000,-100000, 40000},
{- 10000,-100000,- 50000},
{- 15000,-100000, 80000},
{- 70000,-100000, 10000},
{ 100000, 60000,- 30000},
{ 100000, 20000, 40000},
{ 100000, -10000,- 50000},
{ 100000, -15000, 80000},
{ 100000, -70000, 10000},
{-100000,- 30000, 60000},
{-100000, 40000, 20000},
{-100000,- 50000,- 10000},
{-100000, 80000,- 15000},
{-100000, 10000,- 70000}};
int color[STAR_NUM]={ COLOR(31,31,31),
COLOR(28,22,31),
COLOR(20,20,24),
COLOR(28,24,29),
COLOR(31,31,31),
COLOR(31,31,31),
COLOR(31,31,31),
COLOR(31,31,31),
COLOR(24,31,20),
COLOR(24,18,31),
COLOR(31,31,31),
COLOR(20,20,28),
COLOR(31,20,28),
COLOR(24,31,20),
COLOR(24,18,31),
COLOR(31,31,31),
COLOR(20,20,28),
COLOR(31,20,28),
COLOR(24,31,20),
COLOR(24,18,31),
COLOR(31,31,31),
COLOR(20,20,28),
COLOR(31,20,28),
COLOR(31,31,31),
COLOR(31,20,28),
COLOR(24,31,20),
COLOR(24,18,31),
COLOR(31,31,31),
COLOR(20,20,28),
COLOR(31,20,28),
COLOR(24,31,20),
COLOR(24,18,31),
COLOR(31,31,31),
COLOR(20,20,28),
COLOR(24,31,20),
COLOR(24,18,31),
COLOR(31,31,31),
COLOR(20,20,28)};
for(i=0;i<STAR_NUM;i++){
// Y軸の回転
point_w[1][0]=( star_data[i][0] * cos_data[angle[1]] +
star_data[i][2] * sin_data[angle[1]] )>>7;
point_w[1][2]=(-star_data[i][0] * sin_data[angle[1]] +
star_data[i][2] * cos_data[angle[1]] )>>7;
// X軸の回転
point_w[2][1]=( star_data[i][1] * cos_data[angle[0]] -
point_w[1][2] * sin_data[angle[0]])>>7;
point_w[3][2]=((star_data[i][1] * sin_data[angle[0]] +
point_w[1][2] * cos_data[angle[0]])>>7);
// Z軸の回転
point_w[3][0]=((point_w[1][0] * cos_data[angle[2]] -
point_w[2][1] * sin_data[angle[2]])>>7);
point_w[3][1]=((point_w[1][0] * sin_data[angle[2]] +
point_w[2][1] * cos_data[angle[2]])>>7);
// 透視変換&描画
if(point_w[3][2]<=0)continue;
z_w=100000+0x100;
x=(( point_w[3][0]<<8)/z_w)+128;
y=((-point_w[3][1]<<8)/z_w)+120;
if(x>=0 && x<=255 && y>=0 && y<=255)
pset(x,y,color[i],page);
}
}